﻿using System;
using System.Collections.Generic;
using System.Data.SqlClient;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using WebApplication1;

namespace WebApplication3
{
    public partial class WebForm2 : System.Web.UI.Page
    {
        SqlHelper sqlHelper = new SqlHelper();
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            string name = Name.Text;
            string pwd = Pwd.Text;
            string email = Email.Text;
            string intro = Intro.Text;


            string constr = "sever=.;database=Student_db";

            SqlConnection con = new SqlConnection(constr);
            con.Open();
            string sql = "insert into StudentInfo(stu_name,password,email,intro)values(@name,@pwd,@email,@intro)";

            SqlParameter[] pars =
            {
                new SqlParameter("@name",name),
                new SqlParameter("@pwd",pwd),
                new SqlParameter("@email",email),
                new SqlParameter("@intro",intro)
            };
            SqlCommand cmd = new SqlCommand(sql,con);
            cmd.Parameters.AddRange(pars);

            int result = cmd.ExecuteNonQuery();

            if (result>0)
            {
                Literal1.Text = "注册成功<a href='WebForm1.aspx'>去登录<a/>";
            }
            else
            {
                Literal1.Text = "注册失败";
            }

        }
    }
}